@isTest
private class OppSetProjectTypeHandlerTest {
    static testMethod void testMethod1() {
        //客户1
        Account acc = TestUtils.createAccount();
        acc.Level__c = '三级甲等';
        insert acc;     

        //业务机会1
        Opportunity opp = TestUtils.createOpportunity();
        opp.AccountId = acc.Id;
        insert opp;

        

        //产品1    
        Product__c p1 = TestUtils.createProduct();        
        p1.Category1__c = '微生物'; 
        p1.Purpose__c = '仪器报价用';
        p1.RecordTypeId = utils.getRecordTypeIdByDevNameAndObjName('NCProduct', 'Product__c');
   
        Product__c p2 = TestUtils.createProduct();
        p2.Name = 'Test1';
         p2.Purpose__c = '仪器报价用';
        p2.RecordTypeId = utils.getRecordTypeIdByDevNameAndObjName('NCProduct', 'Product__c');

        p2.Category1__c = '免疫';        
        insert new Product__c[] {p1, p2};
        ///意向产品
        IntentProduct__c ip1 = TestUtils.createIntentProduct();
        ip1.Product__c = p1.Id;
        ip1.Opportunity__c = opp.Id;

        ip1.Comment__c = 'Tste===============';
        IntentProduct__c ip2 = TestUtils.createIntentProduct();
        ip2.Product__c = p2.Id;
        ip2.Opportunity__c = opp.Id;   
        insert new IntentProduct__c[] {ip1, ip2};
        System.debug('+++意向计算');
         //OppSetProjectTypeHandler.calcOppSetProjectType(new Set<Id> {opp.Id});
        //报价1
        Quote qt1 = new Quote(Name = '仪器报价',Type__c = '仪器报价',OpportunityId = opp.Id,Status = '填写完毕');
        //报价2
        Quote qt2 = new Quote(Name = '试剂报价',Type__c = '试剂报价',OpportunityId = opp.Id,Status = '填写完毕');
       Quote qt3 = new Quote(Name = '仪器报价',Type__c = '仪器报价',OpportunityId = opp.Id,IsActive__c = true);

        insert new Quote[] { qt1, qt2,qt3 };

        //报价产品1
        QuoteProduct__c qp1 = new QuoteProduct__c(Name = '测试报价产品1',Product__c = p1.Id,Quote__c = qt1.Id);        
        QuoteProduct__c qp2 = new QuoteProduct__c(Name = '测试报价产品2',Product__c = p2.Id,Quote__c = qt2.Id);
        insert new QuoteProduct__c[] {qp1,qp2};
       //  OppSetProjectTypeHandler.calcOppSetProjectType(new Set<Id> {opp.Id});
        qt1.Status = '已批准';
        update qt1;
       // delete qt1 ;
         //测算信息1
        Measure_Calculate__c mc1 = new Measure_Calculate__c(Opportunity__c = opp.Id,Status__c='已提交');
        insert mc1;
         Measure_Calculate__c mc2 = new Measure_Calculate__c(Opportunity__c = opp.Id,Status__c='已提交');
        insert mc2;


        //测算信息产品1
        Measure_Calculate_Product__c mcp1 = new Measure_Calculate_Product__c(Product__c = p1.Id, Measure_Calculate__c = mc1.Id);
        Measure_Calculate_Product__c mcp2 = new Measure_Calculate_Product__c(Product__c = p2.Id, Measure_Calculate__c = mc2.Id);
        insert new Measure_Calculate_Product__c[] {mcp1, mcp2};


        // OppSetProjectTypeHandler.calcOppSetProjectType(new Set<Id> {opp.Id});

        /*Opportunity insertOpp = [select ProjectType__c,id from Opportunity where id = :opp.Id];
        system.assertEquals('多项目', insertOpp.ProjectType__c);

        qp1.Comment__c = '321';

        System.Test.startTest();
        update qp1;
        delete qp1;
        System.Test.stopTest();
        Opportunity deleteOpp = [select ProjectType__c,id from Opportunity where id = :opp.Id];
        system.assertEquals('单项目', deleteOpp.ProjectType__c);*/


    }
}